package com.zuowei.ycy.user.ui.mine.balance;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.and.yzy.frame.util.AppManger;
import com.and.yzy.frame.util.RetrofitUtils;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.config.UserManger;
import com.zuowei.ycy.user.http.Member;
import com.zuowei.ycy.ui.BaseToolbarAty;
import com.zuowei.ycy.user.util.AppJsonUtil;

import butterknife.Bind;
import butterknife.OnClick;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by Administrator on 2016/4/26.
 * 余额转出第一步
 */
public class BalanceZhuanchuTwoAty extends BaseToolbarAty {

    @Bind(R.id.edit_alipay_num)
    EditText editAlipayNum;
    private String money;

    @Override
    public int getLayoutId() {
        return R.layout.balance_zhuanchu_two_aty;
    }

    @Override
    public void initData() {
        mToolbar.setTitle("转出");
        money = getIntent().getStringExtra("money");

    }

    @Override
    public void requestData() {

    }

    @OnClick({R.id.fbtn_confirm})
    @Override
    public void btnClick(View view) {
        super.btnClick(view);
        String alipay_number = editAlipayNum.getText().toString();
        if (TextUtils.isEmpty(alipay_number)) {
            showToast("请先输入支付宝账号");
            return;
        }

        showLoadingDialog("");
        doHttp(RetrofitUtils.createApi(Member.class).rollout(UserManger.getM_id(), money, alipay_number), 0);
    }

    @Override
    public void onSuccess(String result, Call<ResponseBody> call, Response<ResponseBody> response, int what) {
        if (what == 0) {
            showToast(AppJsonUtil.getResultInfo(result).getMessage());
            AppManger.getInstance().killActivity(BalanceZhuanchuOneAty.class);
            finish();
        }
        super.onSuccess(result, call, response, what);
    }
}
